// 类型断言

/**
 * 1. 子类可以直接断言为父类
 * 如果  A，B 如果是类并且有继承关系
 */

class People {
  public myusername!: string;
  public myage!: number;
  public address!: string;
  public phone!: string;
  constructor() {}
  eat() {}
  step() {
    console.log("People=>step");
  }
}

class Stu extends People {
  public username!: string;
  public age!: number;
  public address!: string; // 类型 "Stu" 中缺少属性 "address"，但类型 "typestu2" 中需要该属性。t

  constructor(
    username: string,
    age: number,
    address: string,
    public phone: string
  ) {
    //  super(username, age);
    super();
    this.address = address;
  }
  study() {
    console.log('Stu我在学习');
  }
}

let people = new People();

// let result = people as Stu;// 类型断言
let result = <Stu>people; // 类型断言语法
result.step()
result.eat()
// result.study();//! 报错  People没有study 所以people访问不到stu里面的study


export {}